var url = "http://admin.sx.com/index.php?c=goods&a=getCagegory";

//        var formData = new FormData(document.querySelector('form'));

var formData = new FormData();
formData.append('data', 1);

fetch(url, {
    method: 'POST',
    headers: {},//{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'},
    body: formData
}).then(function (response) {
    return response.json()
}).then(function (json) {
    console.log(json);
    if (json.success) {
        alert("添加成功");
    } else {
        alert("添加失败，已经存在");
    }
}).catch(function (error) {
    console.log(error)
});
function getFetchUrl(url, callback) {
    fetch(url).then(function (response) {
        return response.json();
    }).then(function (json) {
        callback(json);
    }).catch(function (error) {
        console.log(error);
    });
}

function postFetchFormdata(url, formData, callback) {
    fetch(url, {
        method: 'POST',
        body: formData
    }).then(function (response) {
        return response.json();
    }).then(function (json) {
        callback(json);
    }).catch(function (error) {
        console.log(error);
    });
}